package br.com.dojo.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import br.com.dojo.dao.EnderecoDAO;
import br.com.dojo.entity.Endereco;

@Service
@Transactional
public class EnderecoService {
	@Autowired
	EnderecoDAO dao;
	
	public List<Endereco> ListarEndereco(){
		
		List<br.com.dojo.entity.Endereco> listaEnderecos = dao.findAll();
		List<Endereco> result = new ArrayList<Endereco>();
		for (br.com.dojo.entity.Endereco endereco : listaEnderecos) {
			Endereco c = new Endereco();
			c.setRua(endereco.getRua());
			c.setNumero(endereco.getNumero());
			c.setCep(endereco.getCep());
			c.setBairro(endereco.getBairro());
			c.setCidade(endereco.getCidade());
			c.setEstado(endereco.getEstado());
			c.setPais(endereco.getPais());
			result.add(c);
		}
		return result;	
	}	
}